# urls.py
from django.urls import path
from .views import (
    DataSourceListView, DataSourceCreateView, DataSourceUpdateView, DataSourceDeleteView,
    TableListView, TableCreateView, TableUpdateView, TableDeleteView,
    FieldListView
)
from . import views

urlpatterns = [
    # 数据源管理
    path('datasources/', DataSourceListView.as_view(), name='datasource_list'),
    path('datasources/create/', DataSourceCreateView.as_view(), name='datasource_create'),
    path('datasources/<int:pk>/update/', DataSourceUpdateView.as_view(), name='datasource_update'),
    path('datasources/<int:pk>/delete/', DataSourceDeleteView.as_view(), name='datasource_delete'),
    path('api/datasource/<int:datasource_pk>/tables/', views.datasource_tables_api, name='datasource_tables_api'),
    path('api/datasource/<int:datasource_pk>/tables/set_show/', views.set_tables_show, name='set_tables_show'),
    path('api/table/<int:table_id>/fields/', views.table_fields_api, name='table_fields_api'),
    path('api/table/<int:table_id>/fields/set_show/', views.set_fields_show, name='set_fields_show'),
    
    # 表格管理
    path('datasources/<int:datasource_pk>/tables/', TableListView.as_view(), name='table_list'),
    path('datasources/<int:datasource_pk>/tables/create/', TableCreateView.as_view(), name='table_create'),
    path('datasources/<int:datasource_pk>/tables/<int:pk>/update/', TableUpdateView.as_view(), name='table_update'),
    path('datasources/<int:datasource_pk>/tables/<int:pk>/delete/', TableDeleteView.as_view(), name='table_delete'),

    # 字段管理
    path('datasources/<int:datasource_pk>/tables/<int:table_pk>/fields/', FieldListView.as_view(), name='field_list'),
]    